<style type="text/css">
</style>
<template>
    <i-form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="110">
        <Form-item label="控制器名称" prop="controllername">
            <i-input v-model="formValidate.controllername" placeholder="请输入控制器名称"></i-input>
        </Form-item>
        <Form-item label="控制器IP" prop="controllerip">
            <i-input v-model="formValidate.controllerip" placeholder="请输入控制器IP"></i-input>
        </Form-item>
        <Form-item label="控制器端口号" prop="controllerport">
            <i-input v-model="formValidate.controllerport" placeholder="请输入控制器端口号"></i-input>
        </Form-item>
        <Form-item label="是否播放声音" prop="isplaysound">
            <i-select v-model="formValidate.isplaysound" placeholder="请选择是否播放声音">
                <i-option value="true">是</i-option>
                <i-option value="false">否</i-option>
            </i-select>        </Form-item>
        <Form-item label="备注说明" prop="comment">
            <i-input v-model="formValidate.comment" placeholder="请输入备注说明"></i-input>
        </Form-item>
        <Form-item>
            <i-button @click="handleSubmit('formValidate')" type="primary">提交</i-button>
            <i-button type="ghost" style="margin-left: 8px" @click="backGoJump()">返回</i-button>
        </Form-item>
    </i-form>
</template>
<script>

    import apiUtil from '../../assets/utils/api_util';
    import baseUtil from '../../assets/utils/base-util'

    export default {
        data() {
            return {
                formValidate: {
                    //添加字段
                    controllername: '',
                    controllerip: '',
                    controllerport: '',
                    isplaysound: '',
                    comment: '',
                },
                ruleValidate: {
                },
            }
        },
        mounted: function () {},

        methods: {
            //backJump
            backGoJump:function(){
                this.$router.back(-1)

            },
            //添加
            handleSubmit(name) {

                let that = this;
                let model = this.$refs[name].model;
                this.$refs[name].validate((valid) => {
                    that.addData(model);
                })
            },
            addData: function (model) {
                let that = this;

                model.forgatesubsysid = this.$route.query.id;
                let params = that.$qs.stringify(model);
                this.$Loading.start();

                apiUtil.post(that,apiUtil.urls.AddGatesCtrl, params, function (res) {
                    that.$Loading.finish();

                    that.$Notice.open({
                        title: '通知',
                        desc: '添加成功 '
                    });
                    // that.$Modal.confirm({
                    //     title: '操作成功',
                    //     content: '请选择下一步操作',
                    //     okText: '继续添加',
                    //     cancelText: '返回控制器列表',
                    //     onOk: () => {
                    //         // baseUtil.pageJump(that,'','GateServerAdd')
                    //     },
                    //     onCancel: () => {
                    //         baseUtil.pageJump(that,that.$route.query.id,'GateCtrlList')
                    //
                    //     }
                    // });
                });
            },

            uploadList() {
                let that = this;
                this.imageList = that.$refs.upload ? that.$refs.upload.fileList : [];
                console.log('this.imageList:', this.imageList);
                // return ;
            },

        }
    }
</script>
